var id = RequestURLParam.getParam("id");
var type = RequestURLParam.getParam("type");
var urlTxt = "/wf/module/add";
$(document).ready(function () {
    $("#moduleName").focus();
    if (type == "edit") {
        urlTxt = "/wf/module/update";
        init_data();
        $("#legendText").text("修改模块")
    } else {
        $("#legendText").text("添加模块")
    }
});

function init_data(){
    $.post("/wf/module/findById",{"id":id},function (data) {
        if (data.OK == "OK") {
            if (data.wfModule) {
                $(".wfModule").each(function () {
                    $(this).val(data.wfModule[this.id])
                });
            }
        } else {
            parent.layer.alert(data.message);
        }
    });
}

//注意：parent 是 JS 自带的全局对象，可用于操作父页面
var thisindex = parent.layer.getFrameIndex(window.name); //获取窗口索引

layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form
    //监听提交
    form.on('submit(sub)', function(data){
        ActHttpRequest(urlTxt, data.field, function (data) {
            if (data.OK == "OK") {
                parent.layer.msg('成功！', {icon: 1});
                parent.searchData();
                parent.layer.close(thisindex);
            } else {
                parent.layer.alert(data.message);
            }
        });
        return false;
    });
});